<?php
declare(strict_types=1);
namespace Field;

class AuthNickAuthConst
{
    public const pk='';
    public const index=['NickID','ProductID'];
	public const fields=['NickID','ProductID','CreateAt','TimeOut','FreeOut','UpdateAt'];
	public const comment=['NickID'=>'授权编号','ProductID'=>'产品编号','CreateAt'=>'创建时间','TimeOut'=>'到期时间','FreeOut'=>'免费时间','UpdateAt'=>'更新时间'];
	/*
    * @Field NickID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 授权编号
    */
    public const NickID = 'NickID';
    /*
    * @Field ProductID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 产品编号
    */
    public const ProductID = 'ProductID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null NO
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 创建时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field TimeOut
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 到期时间
    */
    public const TimeOut = 'TimeOut';
    /*
    * @Field FreeOut
    * @Type int(10)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 免费时间
    */
    public const FreeOut = 'FreeOut';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新时间
    */
    public const UpdateAt = 'UpdateAt';
}

class AuthNickAuthColumns
{
public  int $NickID;
   public  int $ProductID;
   public  string $CreateAt;
   public  int $TimeOut;
   public  int $FreeOut=0;
   public  ?string $UpdateAt='';
	public function toArray():array
	{
		return [
'NickID'=>$this->NickID,
    'ProductID'=>$this->ProductID,
    'CreateAt'=>$this->CreateAt,
    'TimeOut'=>$this->TimeOut,
    'FreeOut'=>$this->FreeOut,
    'UpdateAt'=>$this->UpdateAt,        ];
	}
}

class AuthNickAuthRow
{
	public AuthNickAuthColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'NickID' => $this->data->NickID,
        'ProductID' => $this->data->ProductID,
        'CreateAt' => $this->data->CreateAt,
        'TimeOut' => $this->data->TimeOut,
        'FreeOut' => $this->data->FreeOut,
        'UpdateAt' => $this->data->UpdateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new AuthNickAuthColumns();
        isset($data['NickID']) && $this->data->NickID = (int)$data['NickID'];
           isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['TimeOut']) && $this->data->TimeOut = (int)$data['TimeOut'];
           isset($data['FreeOut']) && $this->data->FreeOut = (int)$data['FreeOut'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
    }
}
?>